package sort;

public class BubbleSort {
	private long array[];
	private int nElems;
	
	public BubbleSort(int max){
		array=new long[max];
		nElems=0;
	}
	
	public void insert(long value){
		array[nElems]=value;
		nElems++;
	}
	
	public void desplay(){
		for(int j=0;j<nElems;j++){
			System.out.println(array[j]+" ");
		}
	}
	
	public void bubbleSort(){
		int out ,in;
		for(out=nElems-1;out>1;out--){
			for(in=0;in<out;in++){
				if(array[in]>array[in+1]){
					swap(in,in+1);
				}
			}
		}
	}

	private void swap(int in, int i) {
		long temp=array[in];
		array[in]=array[i];
		array[i]=temp;
	}
}
